package org.crh.sms;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.crh.common.ProviderFeignClient;
import org.crh.common.domain.AppointmentRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: RenHai Chen
 * @date: 2025/3/31 10:43
 */
// 订单超时通知
@Service
@RocketMQMessageListener(nameServer = "${spring.rocketmq.name-server}", topic = "ORDER_TIMEOUT_TOPIC", consumerGroup = "sms_timeout_group")
public class TimeoutSmsListener implements RocketMQListener<String> {
    @Autowired
    private ProviderFeignClient providerFeignClient;
    @Autowired
    SmsService smsService;

    public void onMessage(String orderNo) {
        AppointmentRecord order = providerFeignClient.getOrderByOrderNo(orderNo);
        smsService.sendSms(order.getPhone(),
                "订单已超时取消：" + orderNo);
    }
}

